package com.sun.showcase.controller.testcase;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sun.showcase.biz.testcase.service.CaseProjectService;
import com.sun.showcase.pojo.DataGrid;
import com.sun.showcase.pojo.Json;
import com.sun.showcase.client.testcase.domain.CaseProject;
import com.sun.showcase.client.testcase.query.CaseProjectQuery;

@Controller
@RequestMapping(value="/testcase/caseProject") 
public class CaseProjectController{
	
	@Autowired
	private CaseProjectService caseProjectService;
	
	private Json json = new Json();
	/**
	 * 跳转到CaseProject管理页面
	 * 
	 * @return
	 */
	@RequestMapping(value="goCaseProject")
	public String goCaseProject() {
		return "testcase/caseProject";
	}
	/**
	 * 跳转到CaseProject新增页面
	 * 
	 * @return
	 */
	@RequestMapping(value="handleCaseProject")
	public String handleCaseProject(@RequestParam(value="id",required=false) Long id ,ModelMap map) {
		return "testcase/caseProject_rowEdit";
	}

	/**
	 * 跳转到查看desc页面
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="showDesc")
	public CaseProject showDesc(CaseProjectQuery caseProjectQuery) {
		return caseProjectService.get(caseProjectQuery);
	}

	/**
	 * 获得分页数据表格
	 */
	@ResponseBody
	@RequestMapping(value = "/datagrid")
	public DataGrid datagrid(CaseProjectQuery caseProjectQuery) {
		return caseProjectService.datagrid(caseProjectQuery);
	}
	/**
	 * 获得分页数据表格
	 */
	@ResponseBody
	@RequestMapping(value = "/listAll")
	public List<CaseProjectQuery> listAll(CaseProjectQuery caseProjectQuery) {
		return caseProjectService.listAll(caseProjectQuery);
	}
	

	/**
	 * 添加一个CaseProject
	 */
	@ResponseBody
	@RequestMapping(value="add")
	public Json add(CaseProjectQuery caseProjectQuery) {
		caseProjectService.add(caseProjectQuery);
		json.setSuccess(true);
		json.setObj(caseProjectQuery);
		json.setMsg("添加成功！");
		return json;
	}

	/**
	 * 编辑CaseProject
	 */
	@ResponseBody
	@RequestMapping(value="edit")
	public Json edit(CaseProjectQuery caseProjectQuery) {
		caseProjectService.update(caseProjectQuery);
		json.setSuccess(true);
		json.setObj(caseProjectQuery);
		json.setMsg("编辑成功！");
		return json;
	}

	/**
	 * 物理删除CaseProject
	 */
	@ResponseBody
	@RequestMapping(value="delete")
	public Json delete(CaseProjectQuery caseProjectQuery) {
		caseProjectService.delete(caseProjectQuery.getIds());
		json.setSuccess(true);
		json.setMsg("删除成功！");
		return json;
	}
	
	/**
	 * 逻辑删除CaseProject
	 */
	@ResponseBody
	@RequestMapping(value="deletePt")
	public Json deletePt(CaseProjectQuery caseProjectQuery) {
		caseProjectService.deletePt(caseProjectQuery.getIds());
		json.setSuccess(true);
		json.setMsg("删除成功！");
		return json;
	}
}
